package org.flower.web.servlet;

import org.flower.dao.CommodityDetailsDao;
import org.flower.dao.impl.CommodityDetailsDaoImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

/**
 * @author Aizen
 */
@WebServlet("/manager/commodityDeleteServlet.shtml")
public class CommodityDeleteServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String cid = request.getParameter("cid");
        CommodityDetailsDao detailsDao = new CommodityDetailsDaoImpl();
        if(cid!=null&&!cid.equals("")){
            detailsDao.deleteCommodityById(Integer.parseInt(cid));
        }
        request.getRequestDispatcher("commodityListServlet").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
